<template>
  <div class="width-style">
    <LevelOnePageTop moduleName="医学前沿" :catagoryList="catagoryList"/>
    <el-row :gutter="20">
      <el-col :span="18">
        <div class="grid-content">
          <InnerModuleLong innerModuleName="分子医学" :list="moleculeList"  :picSrc="require('@/assets/images/medicalleadingmolecule.jpg')" routeName="/medicalleading/molecule"/>
          <InnerModuleLong innerModuleName="细胞医学" :list="cellList"  :picSrc="require('@/assets/images/medicalleadingcell.jpg')" routeName="/medicalleading/cell"/>
          <InnerModuleLong innerModuleName="元素平衡疗法" :list="elementList" :picSrc="require('@/assets/images/medicalleadingelement.jpg')" routeName="/medicalleading/element"/>
          <InnerModuleLong innerModuleName="信息医学" :list="informationList" :picSrc="require('@/assets/images/medicalleadinginformation.jpg')" routeName="/medicalleading/information"/>
          <InnerModuleLong innerModuleName="磁场疗法" :list="magnetismList" :picSrc="require('@/assets/images/medicalleadingmagnetism.jpg')" routeName="/medicalleading/magnetism"/>
          <InnerModuleLong innerModuleName="光疗法" :list="lightList" :picSrc="require('@/assets/images/medicalleadinglight.jpg')" routeName="/medicalleading/light"/>
          <InnerModuleLong innerModuleName="自然疗法" :list="natureList" :picSrc="require('@/assets/images/medicalleadingnature.jpg')" routeName="/medicalleading/nature"/>
          <InnerModuleLong innerModuleName="免疫疗法" :list="immunizationList" :picSrc="require('@/assets/images/medicalleadingimmunization.jpg')" routeName="/medicalleading/immunization"/>
          <InnerModuleLong innerModuleName="基因疗法" :list="geneList" :picSrc="require('@/assets/images/medicalleadinggene.jpg')" routeName="/medicalleading/gene"/>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content">
          <ModuleAdviser :doctorList="doctorList"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import LevelOnePageTop from '@/components/levelOnePageTop'
import {renderTime} from '@/utils/tools.js'
export default {
  name: "MedicalLeading",
  layout: "homeLayout",
  components: { LevelOnePageTop },
  async asyncData({app}) {
    //获取当前类下的最热文章
    // let res = await app.api.reqGeneralAllByCatalogue(13);
    let res1 = await app.api.reqCoreGeneralByPage(51,1,5);
    let res2 = await app.api.reqCoreGeneralByPage(52,1,5);
    let allArr
    if (res1.code === 200&&res2.code==200) {
      allArr=res1.rows.concat(res2.rows)
      for (let item of allArr) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    //获取医生等列表
    let doctorRes=await app.api.reqAllDoctor();
    if(doctorRes.code===200){
      for(let doctor of doctorRes.rows){
        doctor.doctorAvatar=app.api.BASEURL+doctor.doctorAvatar
      }
    }
    //获取当类下的子分类的文章
    let moleculeRes = await app.api.reqCoreGeneralByPage(44,1,5);//分子医学
    if (moleculeRes.code === 200) {
      for (let item of moleculeRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let cellRes = await app.api.reqCoreGeneralByPage(45,1,5);//细胞医学
    if (cellRes.code === 200) {
      for (let item of cellRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let elementRes = await app.api.reqCoreGeneralByPage(46,1,5);//元素平衡疗法
    if (elementRes.code === 200) {
      for (let item of elementRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let informationRes = await app.api.reqCoreGeneralByPage(47,1,5);//信息医学
    if (informationRes.code === 200) {
      for (let item of informationRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let magnetismRes = await app.api.reqCoreGeneralByPage(48,1,5);//磁场疗法
    if (magnetismRes.code === 200) {
      for (let item of magnetismRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let lightRes = await app.api.reqCoreGeneralByPage(49,1,5);//光疗法
    if (lightRes.code === 200) {
      for (let item of lightRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let natureRes = await app.api.reqCoreGeneralByPage(50,1,5);//自然疗法
    if (natureRes.code === 200) {
      for (let item of natureRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let immunizationRes = await app.api.reqCoreGeneralByPage(51,1,5);//免疫疗法
    if (immunizationRes.code === 200) {
      for (let item of immunizationRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let geneRes = await app.api.reqCoreGeneralByPage(52,1,5);//基因疗法
    if (geneRes.code === 200) {
      for (let item of geneRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    return {
      catagoryList:allArr,
      doctorList:doctorRes.rows,
      moleculeList:moleculeRes.rows,
      cellList:cellRes.rows,
      elementList:elementRes.rows,
      informationList:informationRes.rows,
      magnetismList:magnetismRes.rows,
      lightList:lightRes.rows,
      natureList:natureRes.rows,
      immunizationList:immunizationRes.rows,
      geneList:geneRes.rows,
    }
  },
};
</script>

<style scoped lang="less">
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.grid-content {
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.module-name {
  font-size: 20px;
  .icon-traditional {
    font-size: 24px;
    color: @themeColor;
  }
}
.modern-medical-img {
  width: 100%;
  height: 100%;
}
</style>

